<?php
class ExcelImportor extends CI_Controller {
	function __construct() {
		parent::__construct ();
		$this->load->model ( "helper/Excel_Reader" );
		$this->load->helper ( "form" );
	}
	
	function index() {
		$data ['title'] = "import the excel";
		$this->load->view ( "manager/excelImport", $data );
	}
	
	function doImport() {
		if (is_uploaded_file ( $_FILES ['thuFile'] ['tmp_name'] ))
			print $_FILES ['thuFile'] ['tmp_name'];
		
		$data = new Excel_Reader ( );
		$data->setOutputEncoding ( 'CP1251' );
		$data->read ( $_FILES ['thuFile'] ['tmp_name'] );
		error_reporting ( E_ALL ^ E_NOTICE );
		
		for($h = 0; $h < count ( $data->sheets ); $h ++) {
			for($i = 1; $i <= $data->sheets [$h] ['numRows']; $i ++) {
				for($j = 1; $j <= $data->sheets [$h] ['numCols']; $j ++) {
					echo "\"" . $data->sheets [$h] ['cells'] [$i] [$j] . "\",";
				}
				echo "\n";
			}
		}
	}
}

?>